@echo off
REM 只用于方法调用，没有输出信息，只有errorlevel

setlocal

set pid=%~1
set vid=%~2

set lan=%local_lan%
if "%lan%"=="" set lan=zh 

if "%pid%"=="" (
    REM if type==script echo 请传入pid
    exit /b 1
)
REM vid不是必须的
REM if "%vid%"=="" (
    REM if type==script echo 请传入vid
    REM exit /b 1
REM )

setlocal EnableDelayedExpansion

set deviceId=^&PID_%pid%\

if "%vid%" NEQ "" (
    set deviceId=\VID_%vid%^&PID_%pid%\
)

REM echo deviceId=!deviceId!

REM echo 'wmic path Win32_USBHub get DeviceID  ^| find "!deviceId!"'

REM wmic path Win32_USBHub get DeviceID  | find "!deviceId!"

for /f "tokens=1* delims==" %%I in ('wmic path Win32_USBHub get DeviceID  ^| find "!deviceId!"') do (
    REM if %type%==script (
        REM echo device is found with !deviceId! 
    REM )
    exit /b 0
)

REM if %type%==script (
    REM echo device is not found with !deviceId! 
REM )
exit /b 404

goto:eof